<?php
require_once('../../config.php');
Doctrine::loadModels('../../models');

	$query = new Doctrine_Query();
    $query->from('LkGlossary l')
    			->where('l.category_id = 8 AND l.deleted = 0  
    						AND l.item_id  = 17 OR l.item_id = 29')
            	->orderby('l.item_name');
    $items = $query->execute();	
    
//$dom = new DomDocument('1.0');
//$dom->formatOutput = true;
//
//$root = $dom->createElement( "results" );
//$dom->appendChild( $root );
//
//	foreach ($items as $item){
//		$dn = $dom->createElement( "record" );
//		$dn->setAttribute( 'data', $item['item_id'] );
//		$dn->setAttribute( 'label', $item['item_name'] );
//		$root->appendChild( $dn );
//	}		
//
//header( "Content-type: text/xml");
//echo $dom->saveXML();

/// Return XML
$str.='<results>';
	foreach ($items as $item){
		$str.='<record>';
			$str.='<data>'.$item["item_id"].'</data>';
			$str.='<label>'.$item["item_name"].'</label>';
		$str.='</record>';
	}
$str.='</results>';
   
header ("content-type: text/xml"); 
echo $str;

file_put_contents  ( "out.txt", $str);

?>